package com.dyz.leetcode._05_sort;

public class _922_sortArrayByParityII {
    public int[] sortArrayByParityII(int[] nums) {
        int n = nums.length;
        int[] ans = new int[n];
        int i = 0;
        for (int a : nums) {
            if (a % 2 == 0) {
                ans[i] = a;
                i += 2;
            }
        }
        i = 1;
        for (int a : nums) {
            if (a % 2 == 1) {
                ans[i] = a;
                i += 2;
            }
        }
        return ans;
    }
}
